@extends('admin.layout')
@section('body')

    <!-- 正文开始 -->
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 表格工具栏 -->
                <form class="layui-form toolbar" id="formSearch">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">@lang('common.keyword'):</label>
                            <div class="layui-input-inline">
                                <input name="keyword" class="layui-input"
                                       placeholder="用户ID、用户名"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">参数:</label>
                            <div class="layui-input-inline">
                                <input name="pv" class="layui-input"
                                       placeholder="请求参数"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">URL:</label>
                            <div class="layui-input-inline">
                                <input name="url" class="layui-input"
                                       placeholder="请求地址"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">token:</label>
                            <div class="layui-input-inline">
                                <input name="session" class="layui-input"
                                       placeholder="登录token"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">日期:</label>
                            <div class="layui-input-inline">
                                <input name="date_range" autocomplete="off" id="txtDateRange" class="layui-input"/>
                            </div>
                        </div>
                        <div class="layui-inline">&emsp;
                            <button class="layui-btn icon-btn" lay-filter="searchForm" lay-submit>
                                <i class="iconfont icon-ic_search"></i>@lang('common.search')
                            </button>
                        </div>
                    </div>
                </form>
                <!-- 数据表格 -->
                <table id="adminTable" lay-filter="adminTable"></table>
            </div>
        </div>
    </div>
@stop

@push('script')
    <script type="text/html" id="urlTpl">
        @{{#if(d.method == 'DELETE'){  }}
        <span type="button" class="layui-badge layui-bg-red">DELETE</span>
        @{{#}else if(d.method=='PUT'){  }}
        <span type="button" class="layui-badge layui-bg-orange">PUT</span>
        @{{#}else { }}
        <span type="button" class="layui-badge layui-bg-blue">@{{d.method}}</span>
        @{{#} }}
        @{{d.url}}
    </script>
    <script type="text/javascript">
        layui.use(['layer', 'form', 'table', 'util', 'admin', 'laydate'], function () {
            var $ = layui.jquery, form = layui.form, laydate = layui.laydate;
            layui.laydate.render({
                elem: '#txtDateRange',
                type:'datetime',
                range: '~'
            });
            //加载完成
            var listTableInc = new ListTable("{{admin_url($baseRoute.'pager')}}");
            let rowBarWidth = 30;
            @auth('detail')
            listTableInc.showBar((tb, d) => {
                SystemUtil.openUrl2({
                    content: "{{admin_url($baseRoute.'detail')}}/" + d.id,
                    title: "详情",
                    area: ['1200px', '600px']
                });
                SystemUtil.CurrentTableInc = tb;
            });
            rowBarWidth += 80;
            @endauth
            @auth('params')
            listTableInc.actionBar('<a class="table-btn" title="参数">参数</a>', (tb, d) => {
                SystemUtil.openUrl2({
                    content: "{{admin_url($baseRoute.'params')}}/" + d.id,
                    title: "参数",
                    area: ['650px', '385px']
                });
                SystemUtil.CurrentTableInc = tb;
            });
            rowBarWidth += 80;
            @endauth
            listTableInc.checkbox();
            listTableInc.lineNumber();
            listTableInc.column("@lang('common.id')", "id").setWidth(100);
            listTableInc.column("用户ID", "user_id").setWidth(100);
            listTableInc.column("用户名", "username").setWidth(100);
            listTableInc.column("医院名称", "hospital_name").setWidth(100);
            listTableInc.column("URL", "url").setWidth(400).tpl('#urlTpl');
            listTableInc.column("token", "session_id");
            listTableInc.column("IP", "ip");
            listTableInc.column("操作时间", "time").setWithDateTime();
            listTableInc.render();
            listTableInc.rowBarWidth = rowBarWidth;
        });
    </script>
@endpush
